package HuaWeiPractice;

import java.util.HashMap;

public class Test_HashMap {
    public static void main(String[] args) {
        String drop_bf_table = "drop table usi_ywjh.tb_itg_mid_dev_chk_6mons";//删除已建备份表
        String bf_check_table = "create table usi_ywjh.tb_itg_mid_dev_chk_6mons as select * from bss.tb_itg_mid_dev_chk_6mons";//备份数据到usi_ywjh
        String sw_bf_check_table = "select * from \n" +
                "(select bf.*, \n" +
                "case when cast(bf.PRD_INST_ID as int) BETWEEN 1 AND 50000000000000 THEN 50000000000000+cast(bf.PRD_INST_ID as int) ELSE cast(bf.PRD_INST_ID as int) end as prd_inst_id,\n" +
                "case when cast(bf.prod_offer_inst_id as int) BETWEEN 1 AND 50000000000000 THEN 50000000000000+cast(bf.prod_offer_inst_id as int) ELSE cast(bf.prod_offer_inst_id as int) end as prod_offer_inst_id \n" +
                "from usi_ywjh.tb_itg_mid_dev_chk_6mons bf where bf.latn_id='550') t";

        String[] area_code = new String[]{"552", "553", "554", "555", "556", "557", "558", "559", "560", "561", "562", "563", "564", "566"};
        HashMap<String, String> kv = new HashMap<>();
        kv.put("552", "52000000000000");
        kv.put("553", "53000000000000");
        kv.put("554", "54000000000000");
        kv.put("555", "55000000000000");
        kv.put("556", "56000000000000");
        kv.put("557", "57000000000000");
        kv.put("558", "58000000000000");
        kv.put("559", "59000000000000");
        kv.put("560", "60000000000000");
        kv.put("561", "61000000000000");
        kv.put("562", "62000000000000");
        kv.put("563", "63000000000000");
        kv.put("564", "64000000000000");
        kv.put("566", "66000000000000");
        System.out.println(kv);
        String sw_bf_check_table_u = sw_bf_check_table;
        for (int i = 0; i < area_code.length; i++) {
            sw_bf_check_table_u += " union all " + sw_bf_check_table.replaceAll("550", area_code[i]).replaceAll("50000000000000", kv.get(area_code[i]));
        }
        String sw_bf_check_table_u_551 = sw_bf_check_table_u + " union all " + "select * from usi_ywjh.tb_itg_mid_dev_chk_6mons where bf.latn_id='551';";
        System.out.println(sw_bf_check_table_u_551);
    }
}
